﻿/*document.write('<script type="text/javascript" src="http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js"></script>');*/
var Ucenter = {
    init: function () {
        if ($.browser.msie) Ucenter.Ui.roundCorner($('.pub-tab_head .parent_switcher li'), '<b class="lt"></b><b class="rt"></b>');
        Ucenter.Ui.easyHover($('.pub-tab_content .submenu li'), 'over');
        Ucenter.Ui.easyHover($('.pub-share .icos'), 'ac');
        //        $('.pub-tab_content .submenu li').click(function () {
        //            $('.pub-tab_content .submenu li').removeClass('ac'); $(this).addClass('ac');
        //            var albumID = $(this).attr("albumID");
        //            ShowAlbumInfo(albumID);
        //        });
        //Ucenter.Ui.autoHeight($('.sidebar'), $('.mainbar'));
        ZZ($('.pub-share .zt'));
        function ZZ(ele) {
            ele.unbind('click').click(function () {

                var t = $(this), id = parseInt($.trim(t.attr('id'))), rel = $.trim(t.attr('rel'));
                if (/^[0-9]+$/.test(id) && typeof id === 'number') {
                    var url = 'http://resources.pomoho.com/swf/out_player.swf?flvid=' + id + '&outall=true&domain=video.baomihua.com/' + rel + '&qudao=manage',
					s1 = 'http://video.baomihua.com/' + rel + '/' + id,
					s2 = url,
					s3 = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="480" height="396" id="object"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><param name="movie" value="' + url + '" /><embed src="' + url + '" quality="high" width="480" height="396" allowScriptAccess="always"/></object>',
					s4 = '[flash]' + url + '[/flash]';
                }
                else { alert('ID值异常！'); return false; }
                Ucenter.Event.popLayer.call(this, [t, 'zhuantie_pop_wrap', '<div class="p-poper p-poper_zz"><div class="top"><a title="点击关闭" class="w_close" href=""><b class="close">关闭</b></a></div><h6>此节目地址（URL）</h6><p><input class="linker" type="text" value="' + s1 + '" /></p><h6>把播放器显示到个人空间或Blog</h6><p><input class="linker" type="text" value="' + s2 + '" /></p><h6>HTML代码，适用于个人空间（或其他类型的Blog）</h6><p><input class="linker" type="text" value="" /></p><h6>BBS代码</h6><p><input class="linker" type="text" value="' + s4 + '" /></p></div>'], { 'options': { 'top': t.offset().top + 25, 'width': 300, 'height': 'auto', 'animate': 1, 'close': true, 'load': 1} });
                var zz = $('.zhuantie_pop_wrap');
                zz.find('.linker').eq(2).attr('value', s3).end().mouseover(function () { $(this).select() }).end().find('.w_close').click(function () { $(this).parents('.zhuantie_pop_wrap').hide(); return false });
                return false;
            });
        }
    },
    Common: {
        addEvent: function (target, eventType, functionRef, capture) {
            if (typeof target.addEventListener != 'undefined') {
                target.addEventListener(eventType, functionRef, capture);
            } else if (typeof target.attachEvent != "undefined") {
                target.attachEvent("on" + eventType, functionRef);
            }
        },
        mouseEvent: function (a, b, c, fun1, fun2) {
            switch (a) {
                case 'hover': b.hover(fun1 || function () { $(this).addClass(c); }, fun2 || function () { $(this).removeClass(c); });
                case 'click': b.click(fun1 || function () { $(this).addClass(c); return false });
            }
        }
    },
    Ui: {
        autoHeight: function (a, b) {
            a.height('auto'); b.height('auto');
            a.height() >= b.height() ? b.height(a.height()) : a.height(b.height());
        },
        easyHover: function (a, b, fun1, fun2) {
            a.hover(fun1 || function () { $(this).addClass(b); }, fun2 || function () { $(this).removeClass(b); });
        },
        alternateRowColors: function (a, b, c, d) {
            for (var i = 0, j = a.length; i < j; i++) {
                a.eq(b).css(d);
                b += c;
                if (b > j) break;
            }
        },
        roundCorner: function (a, b) {
            a.append(b);
        },
        Resize: function (im, nWidth, nHeight) {
            var obj = im || document.getElementById(im);
            var w, h, p1, p2;
            p1 = nWidth / nHeight;
            p2 = obj.width / obj.height;
            w = 0;
            h = 0;
            if (p1 < p2) {
                w = nWidth;
                h = nWidth * (1 / p2);
            } else {
                if (obj.width < nWidth && obj.height < nHeight) {
                    w = obj.width;
                    h = obj.height;
                } else {
                    h = nHeight;
                    w = nHeight * p2;
                }
            }
            obj.style.width = w + 'px';
            obj.style.height = h + 'px';
            obj.style.marginTop = (nHeight - h) / 2 + 'px';
        },
        autoThumb: function (path, w, h) {
            $(path).each(function (i) {
                var preldimg = new Image();
                preldimg.onload = function () {
                    setTimeout(function () {
                        Ucenter.Ui.Resize($(path)[i], w, h);
                        preldimg = null;
                    }, 50);
                }
                preldimg.src = $(path)[i].src;
            });
        },
        charCodeAbout: function (str) {
            var sum = 0;
            for (var i = 0; i < str.length; i++) {
                strCode = str.charCodeAt(i);
                if (strCode <= 126 && strCode >= 32) {
                    sum++;
                }
                else { sum += 2; }
            }
            return sum;
        },
        simulateSelect: function (self,ele) {
			if(!self.find(ele)[0]){return false;}
			var ele=$(ele);
            var down = false;
            var cur = ele.find('.selected a'), op = cur.parent().siblings('.options');
            ele.find('.selected a').attr('tabindex', '1').click(function () {
                cur.focus().toggleClass('ac').css('width', op.width() - 8);
                op.toggle().mousedown(function () {
                    down = true;
                }).mouseup(function () {
                    down = false; ele.find('.selected').focus();
                }).find('li').unbind('click').click(function () {
                    cur.text($(this).find('a').text());
                    cur.removeClass('ac').css('width', 'auto');
                    op.hide();
                    $('.p-scrollLoad').html('<div class="pub-loading_s1" style="text-align:left;">数据加载中...</div>')
                    var type = $(this).attr('messageType'), obj = {};
                    obj.type = type;
                    Ucenter.Config.public.simulateSelect(function () {
                        Ucenter.init();
                    }, obj)
                    return false;
                });
                return false;
            }).blur(function () {
                if (down) { return false; }
                cur.removeClass('ac').css('width', 'auto');
                op.hide();
            });
        },
		fixedLayer:function(self,obj){
			var target=$(obj.target),op=obj.option;
			target.css({'position':'fixed','left':op.left,'top':op.top,'width':op.width,'height':op.height,'background':op.background,'margin':op.margin,'line-height':op.lineHeight,'opacity':op.opacity,'border':op.border,'zIndex':op.zIndex}).html(obj.option.label);
			if(window.ActiveXObject){
				target.css({'position':'absolute'});
				pos();
				$(window).scroll(function(){
					pos();
				}).resize(function(){pos();});
				function pos(){
					var top=Math.floor(document.body.scrollTop+document.documentElement.scrollTop+ document.documentElement.clientHeight*(parseInt(op.top)/100)),left=Math.floor(document.body.scrollLeft+document.documentElement.scrollLeft+ document.documentElement.clientWidth*(parseInt(op.top)/100));
					target.css({'top':top,'left':left});	
				}
			}
			return target;
		},
		cardShow: function (self) {//用户名片
		if(!self.find('.user_bar .avatar a')[0]){return false;}
        var t = this, userCardArray = new Array(), uidArray = new Array(), userCard = {};
        self.find('.user_bar .avatar a').hover(function () {
            clearTimeout(t.timer);
            var uid = $(this).attr('href').toString().split('uid=')[1].split('&')[0]; //获得当前用户的uid
            if (/^[0-9]{1,}$/i.test(uid)) {
                if ($.inArray(uid, uidArray) < 0) {
                    var tempVal = PUBAjaxClass.GetUserCardInfo(uid).value;
                    userCard = eval(tempVal)[0];
                    uidArray.push(uid);
                    userCardArray.push(userCard);
                }
                else {
                    var index = $.inArray(uid, uidArray);
                    userCard = userCardArray[index];
                }
            }
            else { alert('非法的ID！'); return false; }
            //数据拼装并调用函数
            var tempHtml = '<div class="poper-usercard" id=\"poper-usercard_' + uid + '\"><div class="userdata"><div class="user_bar"><div class="avatar"><a href="userhome.aspx?uid=' + uid + '" target="_blank" title="' + userCard.name + '">';
            tempHtml += '<img src="' + userCard.avatar + '" alt="' + userCard.name + '" /></a></div></div><div class="userinfo"><ul><li class="name"><a href="userhome.aspx?uid=' + uid + '" target="_blank" title="' + userCard.name + '">';
            tempHtml += userCard.name + '</a></li><li class="domicile"><span class="label">地区：</span>' + userCard.domicile + '</li><li class="riches"><span class="label gz">关注<strong>' + userCard.num[0] + '</strong></span><span class="label fs">粉丝<strong>';
            tempHtml += userCard.num[1] + '</strong></span><span class="label wb">微博<strong>' + userCard.num[2] + '</strong></span></li></ul></div></div>';
            if (curUserID != uid) {
                tempHtml += ' <div class="controlbar"><span class="opera">';
                var userAndUser = PUBAjaxClass.GetUserAndUserRelationStr(curUserID, uid).value;
                if (userAndUser.split('|')[1] == "0") {
                    tempHtml += '<a href="javascript:SubscibeBlog(' + curUserID + ',' + uid + ')">关注</a><span class="g">|</span>';
                } else {
                    tempHtml += '<a href="javascript:DelSubscibeBlog(' + curUserID + ',' + uid + ')">取消关注</a><span class="g">|</span>';
                }
                tempHtml += '<a href="sendmessage.aspx?_recvuserid=' + uid + '">发消息</a><span class="g">|</span>';
                if (userAndUser.split('|')[0] == "0") {
                    tempHtml += '<a href="javascript:AjaxAddFriend(' + curUserID + ',' + uid + ')">加好友</a></span></div>';
                } else if (userAndUser.split('|')[0] == "1") {
                    tempHtml += '<a href="javascript:AjaxDelFriend(' + curUserID + ',' + uid + ')">删除好友</a></span></div>';
                } else {
                    tempHtml += '<a href="javascript:void(0)">等待好友确认</a></span></div>';
                }
            }
            tempHtml += ' <b class="arr"></b></div>';
            Ucenter.Event.popLayer.call(this, [$('.user_bar .avatar a'), 'card_pop_wrap', tempHtml], { 'options': { 'top': $(this).offset().top - 125, 'left': $(this).offset().left, 'width': 300, 'height': 'auto', 'load': 2} });
            if ($.browser.msie) $('<div class="poper-usercard_bg"></div>').appendTo('.poper-usercard').css({ 'width': $('.poper-usercard').width() + 16, 'height': $('.poper-usercard').height() + 16, 'left': '-8px', 'top': '-8px' });
        }, function () {
            var show = false;
            $('.poper-usercard').mouseover(function () { $(this).show(); show = true; }).mouseout(function () { $(this).hide() });
            t.timer = setTimeout(function () { if (!show) $('.poper-usercard').hide(); }, 250);
        });
    	}
    },
    Event: {
        editBox: function (aa) {
            var t1 = $(this), pcl = $('.' + aa[1]), txt = $.trim(t1.text());
            if (txt == '相册描述' || txt == '相册标题' || txt == '') { txt = '' }
            var oldtxt = pcl.val();
            pcl.val(txt).focus().blur(function () {
                var t2 = $('.' + aa[1]); txt = $.trim(t2.val());
                pcl.hide();
                aa[0].removeClass('ac');
                if (txt == '相册描述' || txt == '相册标题' || txt == '') { t1[0].className == 'title' ? txt = '相册标题' : txt = '相册描述' }
                t1.text(txt);
                if (typeof (t1.attr("albumID")) != 'undefined' && txt != oldtxt) {
                    if (t1.attr("class") == "title") {
                        txt = $.trim(txt);
                        if (txt == "" || txt == "相册标题") {
                            art.dialog.alert("相册名不能为空");
                            t2.val(oldtxt);
                        }
                        else if (GetStringLength(txt) > 40) {
                            art.dialog.alert("相册名称最长20个汉字，40个英文字母！");
                            t2.val(oldtxt);
                        } else {
                            managephoto_V2.ModifyAlbumTitle(t1.attr("albumID"), txt);
                            $("#ul_UserAlbumList").html(managephoto_V2.GetUserAlbumList($("#hidUserID").val()).value);
                            $("#ul_UserAlbumList li").attr("class", "");
                            $("#ul_UserAlbumList li[albumID='" + t1.attr("albumID") + "']").attr("class", "ac over");
                            Ucenter.init();
                        }
                    } else {
                        managephoto_V2.ModifyAlbumDesc(t1.attr("albumID"), txt);
                    }
                }
                if (typeof (t1.attr("imgID")) != "undefined" && txt != oldtxt) {
                    managephoto_V2.modifyPhotoInfo(t1.attr("imgID"), txt)
                }
                t2.unbind('blur')
            });
        },
        popLayer: function (aa, ab) {
            var t = $(this), pcl = $('.' + aa[1]), mouseDownOnSelect = false, sum = 0;
            aa[0].removeClass('ac');
            t.addClass('ac');
            t.css('visibility') == 'hidden' || t.css('display') == 'none' ? null : t.focus();
            switch (ab.options.load) {
                case 1: pcl.remove(); break;
                case 2: pcl.remove(); $(aa[2]).hide().appendTo('body').addClass(aa[1]); pcl = $('.' + aa[1]); break
                default: pcl.hide();
            }
            if (!$('.' + aa[1]).length) {
                $(aa[2]).hide().appendTo('body').addClass(aa[1]);
                pcl = $('.' + aa[1]);
            }
            pcl.css({
                'width': typeof ab.options.width == "string" || ab.options.width > 0 ? ab.options.width : t[0].offsetWidth,
                'height': typeof ab.options.height == "string" || ab.options.height > 0 ? ab.options.height : t[0].offsetHeight,
                'left': ab.options && ab.options.left ? ab.options.left : t.offset().left,
                'top': ab.options && ab.options.top ? ab.options.top : t.offset().top + t[0].offsetHeight
            }).mousedown(function () { mouseDownOnSelect = true; }).mouseup(function () { 
				mouseDownOnSelect = false; 
				if(ab.options.autoHide){t.blur()}
				else{t.focus();} 
				ab.options.unlocked ? t.focus() : null; }).scroll(function(){mouseDownOnSelect = false; t.focus()});
            function childHeight() {
                if (ab.options.scroll && ab.options.height && ab.options.height > 0) {
                    for (var i = 0, l = pcl.children().length; i < l; i++) {
                        sum = sum + pcl.children().eq(i).height();
                    }
                    if (sum > ab.options.height) { pcl.css({ 'overflow': 'auto', 'height': ab.options.height }); }
                    else { pcl.css({ 'overflow': 'hidden', 'height': 'auto' }); }
                }
            }
            switch (ab.options.animate) {
                case 1: pcl.slideDown('slow', function () { childHeight(); }); t.addClass('ac'); break;
                default: pcl.show();
            }
            /*t.blur(function(){
            setTimeout(function(){
            pcl.hide();aa[0].removeClass('ac');t.unbind('blur');
            },300)
            });*/
            if (ab.options.close) return false;
            t.unbind('blur').blur(function () {
                if (!mouseDownOnSelect) { pcl.hide(); aa[0].removeClass('ac');}
            });
        },
        keyBoard: {
            UP: 38,
            DOWN: 40,
            DEL: 46,
            TAB: 9,
            RETURN: 13,
            ESC: 27,
            COMMA: 188,
            PAGEUP: 33,
            PAGEDOWN: 34,
            BACKSPACE: 8
        },
        inputText: function (ele, text, oa, ob) {
			if(!ele[0]){return false;}
			var default_text='';
			if(typeof text==='undefined'||text===null){default_text=ele.val();}
            else{default_text=text;}
            ele.val(default_text).focus(function () {
                var t = $(this), t_val = $.trim(t.val());
                if (t_val == '' || t_val == default_text) $(this).val('').css(oa[0]);
            }).blur(function () {
                var t = $(this), t_val = $.trim(t.val());
                if (t_val == '' || t_val == default_text) { t.val(default_text).css(ob[0]); }
            });
        },
        shortCutKey: function (a, b, fun) {
            a.unbind($.browser.opera ? 'keypress' : 'keydown').bind($.browser.opera ? 'keypress' : 'keydown', function (event) {
                if (event.ctrlKey || event.shiftKey) {
                    if (event.keyCode == b[1]) {
                        event.preventDefault();
                        if (fun instanceof Function) fun();
                    }
                }
                else {
                    if (!b[0] && event.keyCode == b[1]) {
                        event.preventDefault();
                        if (fun instanceof Function) fun();
                    }
                }
            })
        },
        Scroll: function (a, b, c) {
            var id = 1, lin = a.find('li').length, group = lin % c.groupNo == 0 ? parseInt(lin / c.groupNo) - 1 : parseInt(lin / c.groupNo);
            b.width(lin * c.liWidth);
            if (group == 0) { a.find('.l,.r').hide(); return false; }
            a.find('.l').click(function () {
                if (id >= 2) {
                    b.animate({ left: -(c.width * (id - 2)) }, c.during);
                    if (id == 2) {
                        $(this).hide();
                    } if (id == group + 1) {
                        a.find('.r').show().attr('title', '向右翻');
                    }
                    id--;
                }
                return false;
            }).end().find('.r').show().click(function () {
                if (id <= group) {
                    b.animate({ left: -(c.width * id) }, c.during);
                    if (id == 1) {
                        a.find('.l').show().attr('title', '向左翻');
                    } if (id == group) {
                        $(this).hide();
                    }
                    id++;
                }
                return false;
            });
        },
        lazyLoad: function (a) {
            //$('img.crs').attr('alt','[图片]');
            checkImg();
            $(window).scroll(function () {
                checkImg();
            }).resize(function () {
                checkImg();
            });
            function checkImg() {
                var doc = document.documentElement || document.body, lazyImg = $('img.crs'), pageHeight = doc.clientHeight, pageWidth = doc.clientWidth, disTop = document.documentElement.scrollTop + document.body.scrollTop;
                lazyImg.each(function (i) {
                    var _self = $(this), imgTop = _self.offset().top;
                    if (imgTop >= disTop - a.height && imgTop <= disTop + pageHeight) {
                        _self.attr('src', function () { return this.getAttribute('crs') }).removeClass('crs').load(function () {
                            Ucenter.Ui.Resize(this, 120, 90);
                        });
                    }
                });
            }
        },
        scrollLoad: function (ele, obj) {
            if (!ele[0]) { return false; }
            var location = document.documentElement.scrollTop + document.body.scrollTop,locker = false,count=1,loadingShow=true,loading=null;
            checkScroll(location);
            $(window).scroll(function () {
                checkScroll(location);
            }).resize(function () {
                checkScroll(location);
            });
            function checkScroll(loc) {
                var doc = document.documentElement || document.body, eleH = ele[0].clientHeight, eleTop = ele.offset().top, pageHeight = doc.clientHeight, disTop = document.documentElement.scrollTop + document.body.scrollTop;
                var eleT = (obj.page === 'bIndex' ? eleH + eleTop - Ucenter.Config.bIndex.scrollLoad.preLoadDis : eleH + eleTop);
                if (disTop + pageHeight >= eleT && disTop >= loc && !locker&&count<10) {
					locker = true;
					if(loadingShow){
						loading=Ucenter.Ui.fixedLayer(document,{target:$('<div class="pub-loading_s1"></div>').appendTo('body'),option:{'left':'50%','top':'50%','width':'200px','height':'60px','margin':'-30px 0 0 -100px','background':'#f0f0f0 url(http://static01.pomoho.com/img/lib/loading_1.gif) no-repeat 30% center','lineHeight':'60px','opacity':0.8,'border':'1px solid #ccc','zIndex':'9999','label':'数据加载中...'}});
						loadingShow=false;
					}
					else{loading.show();}
					setTimeout(function(){
                    Ucenter.Config.public.scrollLoad(function (data,option) {
                        //locker = true;
						//alert(option)
						if(option.EOF){return false;}
                        var rData=$(data).appendTo(ele);
						loading.fadeOut();
                        Ucenter.init();
                        if (obj.page === 'bTinyblog') { Ucenter.bTinyblog.init(rData); }
						count=option.maxPage;
						//disTop=document.documentElement.scrollTop + document.body.scrollTop;
						disTop=document.documentElement.scrollTop + document.body.scrollTop;
						if(parseInt(count)===1){
							if(disTop>200){disTop-=200;}	
						}
						document.documentElement.scrollTop=document.body.scrollTop=disTop;
                        locker = false;
                    }, obj);
					},0)
                }
                location = disTop;
            }
        },
        getCursorPosition: function (textarea) {
            var rangeData = { text: "", start: 0, end: 0 };
            textarea.focus();
            if (textarea.setSelectionRange) {
                rangeData.start = textarea.selectionStart;
                rangeData.end = textarea.selectionEnd;
                rangeData.text = (rangeData.start != rangeData.end) ? textarea.value.substring(rangeData.start, rangeData.end) : "";
            }
            else if (document.selection) {
                var i,
            	oS = document.selection.createRange(),
            	oR = document.body.createTextRange();
                oR.moveToElementText(textarea);
                rangeData.text = oS.text;
                rangeData.bookmark = oS.getBookmark();
                for (i = 0; oR.compareEndPoints('StartToStart', oS) < 0 && oS.moveStart("character", -1) !== 0; i++) {
                    if (textarea.value.charAt(i) == '\r') {
                        i++;
                    }
                }
                rangeData.start = i;
                rangeData.end = rangeData.text.length + rangeData.start;
            }
            return rangeData;
        },
        setCursorPosition: function (textarea, rangeData) {
            if (!rangeData) {
                alert("获取光标位置失败！")
            }
            if (textarea.setSelectionRange) {
                textarea.focus();
                textarea.setSelectionRange(rangeData.start, rangeData.end);
            }
            else if (textarea.createTextRange) {
                var oR = textarea.createTextRange();
                if (textarea.value.length === rangeData.start) {
                    oR.collapse(false)
                    oR.select();
                }
                else {
                    if (rangeData.bookmark) oR.moveToBookmark(rangeData.bookmark);
                    oR.select();
                }
            }
        },
        setCurrsorPositionEnd: function (textarea) {
            var len = textarea.value.length;
            textarea.focus();
            if (document.selection) {
                var range = textarea.createTextRange();
                range.moveStart('character', len);
                range.collapse(true);
                range.select();
            }
        }
    }
}
Ucenter.bImage = {
    init: function () {
        $('.imglist .vdesc,.cover dd .desc').click(function () {
            Ucenter.Event.popLayer.call(this, [$('.imglist .vdesc,.cover dd .desc'), 'pic_editbox_textarea', '<textarea></textarea>'], { 'options': { 'top': $(this).offset().top} });
            Ucenter.Event.editBox.call(this, [$('.imglist .vdesc,.cover dd .desc'), 'pic_editbox_textarea', '<textarea></textarea>']);
            return false;
        });
        $('.cover dd .title').click(function () {
            Ucenter.Event.popLayer.call(this, [$('.cover dd .title'), 'pic_editbox_input', '<input type="text" />'], { 'options': { 'top': $(this).offset().top} });
            Ucenter.Event.editBox.call(this, [$('.cover dd .title'), 'pic_editbox_input', '<input type="text" />']);
            return false;
        });		
        //移动下拉框功能函数参数说明：[事件触发DOM、目标层、目标层数据],{目标层的设置}
        $('.imglist .vopera .move').click(function () {
            var tempHtml = "";
            var albumId = $(this).attr("albumID");
            tempHtml = managephoto_V2.GetUserAlbumSelect(albumId, curUserID).value;
            Ucenter.Event.popLayer.call(this, [$('.imglist .vopera .move'), 'pic_cate_list', tempHtml], { 'options': { 'width': 110, 'height': 136, 'animate': 1, 'scroll': true, 'load': 1, 'autoHide': false} });
            return false;
        });
        $('.imglist .vopera .tougao').click(function () {
            var tempHtml = "";
            tempHtml = managephoto_V2.GetChannelList().value;
            Ucenter.Event.popLayer.call(this, [$('.imglist .vopera .tougao'), 'pic_cate_list', tempHtml], { 'options': { 'width': 110, 'height': 136, 'animate': 1, 'scroll': true, 'load': 1, 'autoHide': false} });
            return false;
        });
		
        Ucenter.Ui.alternateRowColors($('.pannel_con ul'), 0, 2, { 'background-color': '#fcfcfc' });
        $('.upload_pannel .controlbar .deleteall').click(function () {
            $('.upload_pannel .pannel_con ul').remove();
            $('.upload_pannel .pannel_con').html('<p class="notes">暂时没有任何图片</p>');
            return false;
        });
        $('.upload_pannel .pannel_con .opera .delete').click(function () {
            $(this).parents('ul').remove();
            Ucenter.Ui.alternateRowColors($('.pannel_con ul'), 0, 2, { 'background-color': '#fcfcfc' });
            Ucenter.Ui.alternateRowColors($('.pannel_con ul'), 1, 2, { 'background-color': '#fff' });
            if (!$('.upload_pannel .pannel_con ul').length) { $('.upload_pannel .pannel_con').html('<p class="notes">暂时没有任何图片</p>'); return false; }
            return false;
        });
        Ucenter.Ui.autoThumb('.pub-tab_content .cover dt img,.pub-tab_content .imglist .vimg img,.pub-messbox .message .thumbs img',120,90);
		Ucenter.Ui.autoThumb('.add_photo_info .single_photo .vimg img',90,90);
		Ucenter.Ui.autoThumb('.bImage .pub-messbox .message .thumbs img',100,75);
        Ucenter.Ui.easyHover($('.pic_editbox_input'), '', function () { $(this).attr('title', '请输入此相册的标题'); }, function () { $(this).attr('title', ''); });
        Ucenter.Ui.easyHover($('.cover dd .title'), '', function () { $(this).attr('title', '单击这里输入此图片标题'); }, function () { $(this).attr('title', ''); });
        Ucenter.Ui.easyHover($('.imglist .vdesc,.cover dd .desc'), '', function () { $(this).attr('title', '单击这里输入此图片描述'); }, function () { $(this).attr('title', ''); });
        Ucenter.Ui.easyHover($('pic_editbox_textarea'), '', function () { $(this).attr('title', '请输入此图片的描述'); }, function () { $(this).attr('title', ''); });
    }
}
Ucenter.bUserPage = {
    init: function () {
        Ucenter.Ui.autoThumb('.pub-messbox .message .thumbs img', 120, 90);
    }
}
Ucenter.bTinygame = {
    init: function () {
       Ucenter.Event.inputText($('#searchInput'),'搜索小游戏',[{'color':'#333'}],[{'color':'#a5a5a5'}]);
    }
}
Ucenter.bIndex = {
    init: function (self) {
        this.searchInstant();
		Ucenter.Event.inputText($('#searchInput'), null, [{ 'color': '#333'}], [{ 'color': '#a5a5a5'}]);
		Ucenter.Ui.simulateSelect(self,'.p-select_sim');
		this.toggleShow(self,{'hander':'.vipUsers .toogle_click','target':'.vipUsers .usersList','rows':Ucenter.Config.bIndex.usersList.userRows});
		//Ucenter.Event.scrollLoad($('.p-scrollLoad'),{'page':'bIndex'});
    },
    searchInstant: function () {
        /*$('#searchInput').bind($.browser.opera ? "keypress" : "keydown", function (event) {
            if (event.keyCode == Ucenter.Event.keyBoard.RETURN) {
                event.preventDefault();
                var t = $(this);
                SearchData();
                return false;
            }
        }).focus(function () {

        }).blur(function () {
            var t = $(this);
            SearchData();
        });*/
		var ele=$('#searchInput');
		Ucenter.Event.shortCutKey(ele, [false, Ucenter.Event.keyBoard.RETURN], function () {
        	var val=$.trim($('#searchInput').val());
			Ucenter.Config.public.searchInstant({'page':'bIndex','value':val});	
        });
		$('.go_search').click(function(){var val=$.trim($('#searchInput').val());Ucenter.Config.public.searchInstant({'page':'bIndex','value':val});return false;})
    },
	toggleShow:function(self,obj){
		if(!self.find(obj.target)[0]){return false;}
		var target=$(obj.target),hander=$(obj.hander),l=target.children().length,height=target.height();
		target.animate({height:height},'slow');	
		if(l&&l<=Ucenter.Config.bIndex.usersList.rowMaxLength){hander.css({'background':'none','cursor':'default'});return false;}
			hander.toggle(function(){
				$(this).addClass('ac');
				target.animate({height:height*obj.rows},'slow');	
			},function(){
				$(this).removeClass('ac');
				target.animate({height:height},'slow');	
			});	
	}
}
Ucenter.bVideo={
	init:function(){
		Ucenter.Event.Scroll($('#userList'),$('#userBox'),{'width':460,'during':500,'liWidth':42,'groupNo':11});
		this.searchInstant();
		$('.search_pannel .switcher').click(function(){$('.qanda .view_stack').toggle(500);return false;});	
	},
	searchInstant:function(){
		$('#searchInput_keywords,#searchInput_user').bind($.browser.opera?"keypress":"keydown",function(event){
			if(event.keyCode==Ucenter.Event.keyBoard.RETURN){
				event.preventDefault();
				var t=$(this);
				//调用搜索函数,值t.val();
				return false;	
			}	
		}).focus(function(){
			
		}).blur(function(){
			var t=$(this);
			//调用搜索函数,值t.val();
		});
	}	
}
Ucenter.bTinyblog = {
    weiBoImgUrl: "",
    weiBoBolgUrl: "",
    weiBoVideoUrl: "",
	hidUserID:$('#hidUserID').val(),
    init: function (self) {
		if(typeof self==='undefined'){self=$(document);}
        Ucenter.Event.lazyLoad({ 'height': 90 });
        this.popup($('.funbox .upload_video'), 'video_pop_wrap', '<p>输入视频地址<br /><span class="note">目前仅支持爆米花网站内的视频链接<br>您可以直接填写视频播放地址</span></p>');
        this.popup($('.funbox .upload_blog'), 'blog_pop_wrap', '<p>输入博文地址<br /><span class="note">目前仅支持爆米花网站内的博文链接<br>如：http://www.baomihua.com/blog/博文ID</span></p>');
        this.popup($('.funbox .upload_pic'), 'pic_pop_wrap', '<p>输入图片地址<br /><span class="note">目前仅支持爆米花网站内的图片链接<br>如：http://www.baomihua.com/img/图片ID<br>或者您右键单个图片，属性里面的图片地址</span></p>');
        Ucenter.Ui.cardShow(self);
        this.countTxt($('#msgTxt'), $('.action_pannel .countTxt'));
        Ucenter.Event.shortCutKey($('#msgTxt'), [true, Ucenter.Event.keyBoard.RETURN], function () {
            if (Ucenter.bTinyblog.checkSubmit($('#msgTxt'), $('.action_pannel .countTxt'))) {
                addWeiBo();
				$('.action_pannel .funbox .insert').find('.del').trigger('click');
            }
        });
        Ucenter.Ui.easyHover($('.talk_pannel ul.message>li'), 'ac');
        this.commentLoad();
        $('.action_pannel input.send_btn').unbind('click').click(function () {
            if (Ucenter.bTinyblog.checkSubmit($('#msgTxt'), $('.action_pannel .countTxt'))) {
                addWeiBo();
				$('.action_pannel .funbox .insert').find('.del').trigger('click');
            }
        });
        this.videoPlay();
        this.deleteMine();
		
        //Ucenter.Event.setCurrsorPositionEnd($('#msgTxt')[0]);
    },
	init_once:function(){
		this.gotoTop();	
	},
    variable: {
        limitedWord: 140,
        cursorPosition: {}
    },
	gotoTop:function(){
		var goTop=null,ele=$('.talk_pannel');
		if(ele.offset()){var eleOffset=ele.offset(),left=eleOffset.left+ele.width(),top=eleOffset.top;	}	
		$(window).scroll(function(){
			var st=document.documentElement.scrollTop+document.body.scrollTop
			if(st>=top){
				if(goTop){goTop.fadeIn();}
				else{
					goTop=$('<div class="p-gotoTop"><a class="btn_goTop" href="" title="返回顶部">返回顶部</a></div>').appendTo('body').css('left',left);
				}
				goTop.click(function(){
					document.documentElement.scrollTop=document.body.scrollTop=0;
					return false;	
				});
				if(window.ActiveXObject&&!window.XMLHttpRequest){
					goTop.css('top',st+document.documentElement.clientHeight-goTop.height());	
				}
			}
			else{
				if(goTop)goTop.fadeOut();	
			}	
		});
	},
    checkUrl: function (type, url) {
        var err = { result: false, message: '', pic: false }
        switch (type) {
            case 0:
                if (/(^(http:\/\/)?(www\.)?(pomoho|baomihua)\.com\/img\/[0-9]{1,}((\/?)|(\?[0-9a-z]{1,})?)$)|(^(http:\/\/)?(www\.)?pomoho\.com\/v2\/ImageShow\.aspx\?id\=[0-9]{1,}$)|(^(http:\/\/)?(www\.)?baomihua\.com\/ImageShow\.aspx\?id\=[0-9]{1,}$)/i.test(url)) {
                    err.result = true;
                }
                else if (/^(http:\/\/)?([\w]+\.)?(pomoho|baomihua)\.com(\/[\w-   \.\/\?%&=]*)?\.(jpg|png|gif)$/i.test(url)) {
                    err.result = true;
                    err.pic = true;
                }
                else {
                    err = { result: false, message: '输入的图片地址格式不正确!' }
                }
                return err;
                break;
            case 1:
                if (/(^(http:\/\/)?home\.pomoho\.com\/[0-9a-z_-]{1,}\/[0-9]{1,}((\/?)|(\?[0-9a-z]{1,})?)$)|(^(http:\/\/)?video\.(pomoho|baomihua)\.com\/[0-9a-z_-]{1,}\/[0-9a-z_-]{1,}((\/?)|(\?[0-9a-z_-]{1,})?)$)/i.test(url)) {
                    err.result = true;
                }
                else {
                    err = { result: false, message: '输入的视频地址格式不正确!' }
                }
                return err;
                break;
            case 2:
                if (/(^(http:\/\/)?home\.pomoho\.com\/[0-9a-z]{1,}\/blogview\/[0-9a-z]{1,}((\/?)|(\?[0-9a-z]{1,})?)$)|(^(http:\/\/)?(www\.)?pomoho\.com\/v2\/blogshow\.aspx\?id\=[0-9]{1,}$)|(^(http:\/\/)?(www\.)?baomihua\.com\/blog\/[0-9]{1,}((\/?)|(\?[0-9a-z]{1,})?)$)/i.test(url)) {
                    err.result = true;
                }
                else {
                    err = { result: false, message: '输入的博客地址格式不正确!' }
                }
                return err;
                break;
        }
    },
    countTxt: function (a, b) {
        var t = this;
        total();
        a.bind(($.browser.msie ? 'propertychange' || 'keyup' : 'input'), function () {
            total();
        });
        function total() {
            var strNo = Ucenter.Ui.charCodeAbout($.trim(a.val()));
            var wordNo = Math.ceil(strNo / 2);
            wordNo <= t.variable.limitedWord ? b.html('还能输入<em>' + (t.variable.limitedWord - wordNo) + '</em>字') : b.html('超出<em class="error">' + (wordNo - t.variable.limitedWord) + '</em>字');
        }
    },
    checkSubmit: function (a, b) {
        a.focus();
        var strNo = Ucenter.Ui.charCodeAbout($.trim(a.val())), wordNo = Math.ceil(strNo / 2);
        if (wordNo > this.variable.limitedWord) { b.html('超出<em class="error">' + (wordNo - this.variable.limitedWord) + '</em>字').hide().fadeIn(); return false; }
        if (wordNo == 0 || typeof wordNo == 'undefined') { b.html('<span class="error">请输入内容</span>').hide().fadeIn(); return false; }
        //这里放微博发布提交接口
        return true;
    },
    popup: function (a, b, s) {//视频、博文、图片等外链弹出层
        var t = this;
        a.unbind('click').click(function () {
            var _self = $(this), color = _self.css('color');
            if (_self.data('locker')) { return false; }
            $('.poper-link').hide();
            t.variable.cursorPosition = Ucenter.Event.getCursorPosition($('#msgTxt')[0]);
            Ucenter.Event.popLayer.call(this, [a, b, '<div class="poper-link"><a title="关闭" class="close" href="#">关闭</a>' + s + '<p class="former"><input type="text" class="inputTxt" /><input type="submit" value="确定" class="pub-btn btn" title="快捷键 Enter" /></p><p class="error"></p><b class="arr"></b></div>'], { 'options': { 'top': $(this).offset().top + 20, 'left': $(this).offset().left - 60, 'width': 'auto', 'height': 'auto', 'close': true} });
            var layer = $('.' + b), ipt = layer.find('input.inputTxt');
            ipt.focus();
            var i = $('.funbox .insert').index(_self[0]), error = layer.find('.error');
            error.html('');
            layer.find('input.btn').unbind('click').click(function () {
                dealUpload();
                return false;
            });
            Ucenter.Event.shortCutKey(ipt, [false, Ucenter.Event.keyBoard.RETURN], function () {
                dealUpload();
            });
            function dealUpload() {
                var text = $.trim(layer.find('input.inputTxt').val()), err = t.checkUrl(i, text);
                if (!err.result) {
                    error.html(err.message);
                    return false;
                }
                switch (i) {
                    case 0:
                        //这里将url地址解析出图片路径，希望这里能搞个异步的获取图片页的图片信息，也就是图片页面地址放进去后点确定能即时分析出图片地址，如果图片不存在能及时提醒用户
                        $('<img src="' + text + '" alt="" />').appendTo(_self.css('color', '#999').text('图片已提交').append('<b class="del" title="删除">删除</b>')).hide();
                        Ucenter.bTinyblog.weiBoImgUrl = layer.find('input.inputTxt').val();
                        _self.data('locker', true); //图片链接按钮上锁
                        $(_self).find('.del').click(function () {
                            _self.empty().text('图片').css('color', color).data('locker', false);
                            Ucenter.bTinyblog.weiBoImgUrl = "";
                        }); //删除后解锁
                        layer.hide();
                        break;
                    case 1:
                        _self.css('color', '#999').text('视频已提交').append('<b class="del" title="删除">删除</b>').data('locker', true); //视频上传后按钮上锁
                        Ucenter.bTinyblog.weiBoVideoUrl = layer.find('input.inputTxt').val();
                        $(_self).find('.del').click(function () {
                            _self.empty().text('视频').css('color', color).data('locker', false);
                            Ucenter.bTinyblog.weiBoVideoUrl = "";
                        }); //删除后解锁
                        layer.hide();

                        break;
                    case 2:
                        _self.css('color', '#999').text('博文已提交').append('<b class="del" title="删除">删除</b>').data('locker', true); //视频上传后按钮上锁
                        Ucenter.bTinyblog.weiBoBolgUrl = layer.find('input.inputTxt').val();
                        Ucenter.Event.setCursorPosition($('#msgTxt')[0], t.variable.cursorPosition);
                        $(_self).find('.del').click(function () {
                            _self.empty().text('博文').css('color', color).data('locker', false);
                            Ucenter.bTinyblog.weiBoBolgUrl = "";
                        }); //删除后解锁
                        layer.hide();
                        break
                }
            }
            function addCon() {
                layer.hide();
                Ucenter.bTinyblog.weiBoBolgUrl = layer.find('input.inputTxt').val();
                Ucenter.Event.setCursorPosition($('#msgTxt')[0], t.variable.cursorPosition);
                //$('#msgTxt').insertAtCaret($.trim(layer.find('input.inputTxt').val()));
                //t.countTxt($('#msgTxt'), $('.action_pannel .countTxt'));
            }
            layer.find('.close').click(function () {//层的关闭按钮
                layer.hide();
                Ucenter.bTinyblog.weiBoBolgUrl = "";
                return false;
            });
            return false;
        });
    },
    commentLoad: function () {//评论、转发加载
		function checkLogined(){
			var hidUserID=parseInt(Ucenter.bTinyblog.hidUserID);
			if(hidUserID==0){
				art.dialog({
        			title: '提示信息',
        			content:'<p>您还未登录，请先登录！</p>',
        			lock: false,
					fixed:true,
					resize:false,
					icon:'error',
        			skin: 'facebook',
        			width: 200,
        			height: 150,
        			esc: false,
					time:2
    			});
				return false;	
			}
			else{return true;}	
		}
        $('.talk_pannel .controlbar .pl').unbind('click').click(function () {//评论
			if(!checkLogined()){return false;}
            var msgBox = $(this).parents('.msgbox');
            var noteId = $(this).attr("noteId");
            if (msgBox.find('.commentPannel')[0]) {
                msgBox.find('.inputTxt').focus();
                return false;
            }
            msgBox.data('zf', msgBox.find('.inputTxt').val());
            $('.talk_pannel .replylist').remove();
            var commentPannel = $('<div class="replylist commentPannel"></div>').appendTo(msgBox), loading = '<div class="pub-loading_s1">正在加载...</div>';
            $('<div class="top"><a href="" class="w_close" title="点击关闭"><b class="close">关闭</b></a></div><div class="talkbox"><textarea class="inputTxt"></textarea><div class="funbox"><input type="button" class="pub-btn send_btn" tabindex="2" value="评论" /><span class="countTxt">还能输入<em>140</em>字</span></div></div>' + loading).appendTo(commentPannel);
            msgBox.find('.inputTxt').focus();
            if (msgBox.data('pl')) { msgBox.find('.inputTxt').val(msgBox.data('pl')) }
            Ucenter.bTinyblog.countTxt(msgBox.find('.inputTxt'), msgBox.find('.countTxt'));
            Ucenter.Event.shortCutKey(msgBox.find('.inputTxt'), [true, Ucenter.Event.keyBoard.RETURN], function () {
                if (Ucenter.bTinyblog.checkSubmit(msgBox.find('.inputTxt'), msgBox.find('.countTxt'))) {
                    CommentWeiBo(msgBox.find('.inputTxt').val(), curUserID, noteId);
                }
            });
            msgBox.find('.send_btn').click(function () {
                if (Ucenter.bTinyblog.checkSubmit(msgBox.find('.inputTxt'), msgBox.find('.countTxt'))) {
                    CommentWeiBo(msgBox.find('.inputTxt').val(), curUserID, noteId);
                    msgBox.find('.inputTxt').val("");
                }
            });
            //下面这段代码通过ajax加载，数据加载完成后才执行msgBox.find('.pub-loading_s1').hide();也就是数据加载w完成后取消正在加载的字样//注意！
            msgBox.find('.pub-loading_s1').hide(); //隐藏加载中字样
            //数据加载后插入到层中
            var tempHtml = PUBAjaxClass.GetCommnetList(noteId, 1).value;
            $('<div class="cont" id="comment_' + noteId + '">' + tempHtml + '</div>').appendTo(commentPannel);
            //$('<div class="cont"><div class="comment"><ul><li><span class="username"><a href="">张三：</a></span><p class="msgcon">OK</p><span class="notes">57分钟前 来自网页</span></li><li><span class="username"><a href="">张三：</a></span><p class="msgcon">OK</p><span class="notes">57分钟前 来自网页</span></li></ul></div><div class="more"><b>1</b><a href="">2</a><a href="">3</a><span>...</span><a href="">下一页</a></div></div>').appendTo(commentPannel);
            msgBox.find('.w_close').click(function () { msgBox.data('pl', msgBox.find('.inputTxt').val()); commentPannel.remove(); $('.talk_pannel ul.message>li').removeClass('ac'); return false; });
            return false;
        });
        $('.talk_pannel .controlbar .zf').unbind('click').click(function () {//转发
			if(!checkLogined()){return false;}
            var msgBox = $(this).parents('.msgbox');
            var noteId = $(this).attr("noteId");
            if (msgBox.find('.transmitPannel')[0]) {
                msgBox.find('.inputTxt').focus();
                return false;
            }
            msgBox.data('pl', msgBox.find('.inputTxt').val());
            $('.talk_pannel .replylist').remove();
            var commentPannel = $('<div class="replylist transmitPannel"></div>').appendTo(msgBox), loading = '<div class="pub-loading_s1">正在加载...</div>';
            $('<div class="top"><a href="" class="w_close" title="点击关闭"><b class="close">关闭</b></a></div><div class="talkbox"><textarea class="inputTxt"></textarea><div class="funbox"><input type="button" class="pub-btn send_btn" tabindex="2" value="转发" /><span class="countTxt">还能输入<em>140</em>字</span></div></div>' + loading).appendTo(commentPannel);
            msgBox.find('.inputTxt').focus();
            if (msgBox.data('zf')) { msgBox.find('.inputTxt').val(msgBox.data('zf')) }
            Ucenter.bTinyblog.countTxt(msgBox.find('.inputTxt'), msgBox.find('.countTxt'));
            Ucenter.Event.shortCutKey(msgBox.find('.inputTxt'), [true, Ucenter.Event.keyBoard.RETURN], function () {
                if (Ucenter.bTinyblog.checkSubmit(msgBox.find('.inputTxt'), msgBox.find('.countTxt'))) {
                    RelayUserWeiBo(msgBox.find('.inputTxt').val(), curUserID, noteId);
                }
            });
            msgBox.find('.send_btn').click(function () {
                if (Ucenter.bTinyblog.checkSubmit(msgBox.find('.inputTxt'), msgBox.find('.countTxt'))) {
                    RelayUserWeiBo(msgBox.find('.inputTxt').val(), curUserID, noteId);
                }
            });
            //下面这段代码通过ajax加载，数据加载完成后才执行msgBox.find('.pub-loading_s1').hide();也就是数据加载w完成后取消正在加载的字样//注意！
            msgBox.find('.pub-loading_s1').hide();
            var tempHtml = PUBAjaxClass.GetReplyList(noteId, 1).value;
            $('<div class="cont" id="Reply_' + noteId + '">' + tempHtml + '</div>').appendTo(commentPannel);
            //数据加载后插入到层中
            //$('<div class="cont"><div class="comment"><ul><li><span class="username"><a href="">李四：</a></span><p class="msgcon">OK</p><span class="notes">57分钟前 来自网页</span></li><li><span class="username"><a href="">李四：</a></span><p class="msgcon">OK</p><span class="notes">57分钟前 来自网页</span></li></ul></div><div class="more"><b>1</b><a href="">2</a><a href="">3</a><span>...</span><a href="">下一页</a></div></div>').appendTo(commentPannel);
            msgBox.find('.w_close').click(function () { msgBox.data('zf', msgBox.find('.inputTxt').val()); commentPannel.remove(); $('.talk_pannel ul.message>li').removeClass('ac'); return false; });
            return false;
        });
    },
    videoPlay: function () {//插入视频播放器
        $('.videobox .vThumbsBox').unbind('click').click(function () {
            var t = $(this), videoBox = t.parents('.videobox'), playurl = "/common/pomoho_player_mp4.swf?playurl=" + videoBox.attr('playurl');
            if (t.attr("type") == "M") {
                t.hide();
                videoBox.siblings('.picbox').hide().end().addClass('vPlay').find('.vTools').show().find('.vClose').click(function () {
                    t.show();
                    videoBox.siblings('.picbox').show().end().removeClass('vPlay').find('.vTools').hide().end().find('.vBox').remove();
                    return false;
                });
                $('<div class="vBox loading"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://resources.pomoho.com/swf/out_player.swf?playurl=" width="550" height="476" id="object"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><param name="movie" value="' + playurl + '" /><embed src="' + playurl + '" quality="high" width="500" height="486" allowScriptAccess="always"/></object></div>').appendTo(videoBox.find('.vWrap'));
                return false;
            }
        });
    },
    deleteMine: function () {//删除自己的微博
        $('.talk_pannel .controlbar .delete').unbind('click').click(function () {
            var uid = $(this).attr("uid"); //获取当前用户id
            var nid = $(this).attr("nid");
            if (/^[0-9]{1,}$/i.test(uid)) {
                $(this).parents('li').fadeOut();
                //这里写删除的接口 当前ID为uid
                delWeiBo(uid, nid);
            }
            else { alert('非法的ID！'); }
            return false;
        });
    }
}
Ucenter.bBlog={
	init:function(self){
		Ucenter.init(self);	
	}	
}
Ucenter.bMessage={
	init:function(){
		
	}	
}
Ucenter.bGroup={
	init:function(self){
		if(!/bTinyblog/.test(document.body.className))Ucenter.Ui.cardShow(self);
	}	
}
$(function () {
    Ucenter.init();
    var dc=document.body.className.split(' '),l=dc.length,re=false;
    for(var i=0;i<l;i++){
		if(/^bIndex|bVideo|bImage|bBlog|bTinyblog|bUserPage|bTinygame|bMessage|bGroup$/i.test(dc[i])){Ucenter[dc[i]].init($(document));}
		if(/^bTinyblog$/.test(dc[i])){Ucenter[dc[i]].init_once();}
		if(/^bTinyblog$/.test(dc[i])){
			Ucenter.Event.scrollLoad($('.p-scrollLoad'),{'page':'bTinyblog'});
			re=true;
		}
	}
	if(!re){
		for(var i=0;i<l;i++){
			if(/^bIndex|bBlog|bImage|bUserPage$/.test(dc[i])){
				Ucenter.Event.scrollLoad($('.p-scrollLoad'),{'page':dc[i]});
			}
		}
	}
});
(function($){//插件库
	$.fn.extend({
		insertAtCaret: function(myValue){
			var $t=$(this)[0];
			if (document.selection) {
				this.focus();
				sel = document.selection.createRange();
				sel.text = myValue;
				this.focus();
			}
			else 
				if ($t.selectionStart || $t.selectionStart == '0') {
					var startPos = $t.selectionStart;
					var endPos = $t.selectionEnd;
					var scrollTop = $t.scrollTop;
					$t.value = $t.value.substring(0, startPos) + myValue + $t.value.substring(endPos, $t.value.length);
					this.focus();
					$t.selectionStart = startPos + myValue.length;
					$t.selectionEnd = startPos + myValue.length;
					$t.scrollTop = scrollTop;
				}
				else {
					this.value += myValue;
					this.focus();
				}
		}
	})	
})(jQuery);
Ucenter.Config = {//用户中心配置
    public: {
        scrollLoad: function (callback, obj) {
            if (typeof this.dataType === 'undefined' && !this.dataType) { this.dataType = 'videoData'; }
            switch (obj.page) {
                case 'bIndex':
                    var curPage = parseInt($("#PageIndex").val());
                    if (curPage < 10) {
                        //ViewMessage($("#messageType").val(), pageIndex - 1);
                        var channelId = $("#hidChannelID").val();
                        var columnId = $("#hidColumnID").val();
                        var mesType = $("#messageType").val();
                        if (mesType == "SearchData") {
                            var data = "";
                            SearchVideoByKeyWord(curPage + 1);
                        }
                        else {
                            var data = GetVideoList(channelId, columnId, mesType, curPage + 1);
                        }
						$("#PageIndex").val(curPage + 1);
                        Ucenter.init();
                        
                    }
					var option={'maxPage':curPage}
					if(parseInt(data)===-1){option.EOF=true;}
                    break;
                case 'bTinyblog':
                    var curPage = parseInt($("#PageIndex").val());
                    var userID = $("#hidUserID").val();
                    var hidTopicID = parseInt($("#hidTopicID").val());
                    if (curPage >= 1 && curPage <= 10) {
                        var data = ShowWeiboList(curPage, userID, hidTopicID);
                        curPage = parseInt($("#PageIndex").val());
                        $("#PageIndex").val(curPage + 1);
                    }
                    var option = { 'maxPage': curPage }
                    break;
                case 'bBlog':
                    var curPage = parseInt($("#PageIndex").val());
                    if (curPage < 10) {
                        //ViewMessage($("#messageType").val(), pageIndex - 1);
                        var channelId = $("#hidChannelID").val();
                        var data = GetBlogList(channelId, curPage + 1);
                       
                        $("#PageIndex").val(curPage + 1);
                        Ucenter.init();

                    }
                    var option = { 'maxPage': curPage }
                    if (parseInt(data) === -1) { option.EOF = true; }
                    break;
				case 'bUserPage':
				    var curPage = parseInt($("#pageIndex").val()) + parseInt("1");
				    var userID = $("#userID").val();
				    var visitUserID = $("#hidVisitUserID").val();
				    var pageNum = $("#pageNum").val();
				    if (curPage >= 1 && curPage <= 10 && curPage <= pageNum) {
				        var data = ShowUserNewsList(userID, visitUserID, curPage);
				        $("#pageIndex").val(curPage);
				        //$("#newsCount").html($("#newsCount").html() + content);
				    }
				    var option = { 'maxPage': curPage }
				    break;
                 case 'bImage':
				    var curPage = parseInt($("#PageIndex").val());
				    if (curPage < 10) {
				        var channelId = $("#hidChannelID").val();
				        var data = GetImgList(channelId, curPage + 1);

				        $("#PageIndex").val(curPage + 1);
				        Ucenter.init();

				    }
				    var option = { 'maxPage': curPage }
				    if (parseInt(data) === -1) { option.EOF = true; }
				    break;
            }
            callback(data,option); //回调函数	
        },
        searchInstant: function (obj) {
            switch (obj.page) {
                case 'bIndex':
                    SearchData();
                    break;
            }
        },
        simulateSelect: function (callback, obj) {
            var type = obj.type
            var channelId = $("#hidChannelID").val();
            var columnId = $("#hidColumnID").val();
            $("#messageType").val(type)
            var data = GetVideoList(channelId, columnId, type, 1);
            $("#PageIndex").val(1);
            $('.p-scrollLoad').html(data);
            Ucenter.init();
            this.dataType = 'videoData';
            callback(data);
        }
    },
    bIndex: {
        usersList: { 'userRows': 2, 'rowMaxLength': 7 }, //点击后显示行数
        scrollLoad: { preLoadDis: 200 }
    }
}